package com.bana.fvs.controller;

import com.bana.sys.code.DatabaseResult;
import com.bana.fvs.dao.VisibilityScaleDAO;
import com.bana.fvs.model.VisibilityScale;
import com.bana.fvs.service.VisibilityScaleService;
import com.bana.sys.utils.TokenRequest;
import com.bana.sys.utils.ActionResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 能见度等级
 */
@RestController
@RequestMapping(value = "/scale", method = RequestMethod.POST)
public class VisibilityScaleController {

    @Resource
    private VisibilityScaleDAO visibilityScaleDAO;

    @Resource
    private VisibilityScaleService visibilityScaleService;


    /**
     * 查询能见度等级集合
     * @param request 只用到了token
     * @return 能见度等级集合
     */
    @RequestMapping(value = "/getVisibilityScales.do", method = RequestMethod.POST)
    public List<VisibilityScale> getVisibilityScales(@RequestBody TokenRequest<VisibilityScale> request){
        return visibilityScaleService.getVisibilityScales(request.getData().getWqbm());
    }

    /**
     * 更新能见度等级
     * @param request 请求数据
     * @return
     */
    @RequestMapping(value = "/updateVisibilityScale.do", method = RequestMethod.POST)
    public ActionResult updateVisibilityScale(@RequestBody TokenRequest<VisibilityScale> request){
        visibilityScaleService.updateVisibilityScale(request.getData());
        ActionResult actionResult=new ActionResult();
        actionResult.setCzjg(DatabaseResult.Success);
        return actionResult;
    }


}
